﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.NetworkInformation;

//Sense connected interfaces
namespace SensorDetection
{
    class InterfaceSensor : Sensor
    {
        List<NetworkInterface> interfaces = new List<NetworkInterface>();
        //private NetworkInterface[] interfaces;
        public InterfaceSensor()
        {
            name = "Interface Sensor";
            if (NetworkInterface.GetIsNetworkAvailable())
            {
                interfaces = NetworkInterface.GetAllNetworkInterfaces().ToList();
                data = interfaces;
            }
            //check to make sure the contents of interfaces/newinterfaces are different
            else
            {
                Console.WriteLine("No Network Interfaces Available");
                data = null;
            }
        }

        public void set()
        {
            if (NetworkInterface.GetIsNetworkAvailable())
            {
                NetworkInterface[] newinterfaces;
                newinterfaces = NetworkInterface.GetAllNetworkInterfaces();
                interfaces = NetworkInterface.GetAllNetworkInterfaces().ToList();
                data = interfaces;
                Notify();
                //check to make sure the contents of interfaces/newinterfaces are different, good way to do this?
            }
            else
            {
                Console.WriteLine("No Network Interfaces Available");
            }
        }
    }
}
